We will adopt the fork and branch Git Workflow. The fork and branch workflow is a common way of collaborating on open source projects using Git and GitHub.
Basically, the fork and branch workflow looks something like this:
Install Git in your computer and create an account in GitHub.
Open the web browser and visit the link https://github.com/pucdata/pythonclub
Click the icon Fork located in the top-right of the window
Create a folder in your computer for storing all your Github repositories. We recommed creating the folder Github in your HOME. Open the terminal and execute the following commands.
cd ~
mkdir Github
cd Github
Setup a couple of Github parameters. Replace vim with your favorite editor, YOUR_NAME with your Name and YOUR_EMAIL with your email address
git config credential.helper store
git config --global core.editor "vim"
git config --global push.default current
git config --global user.name "YOUR_NAME"
git config --global user.email "YOUR_EMAIL"
Clone the pythonclub repository from the Github server to your local computer (origin). Replace YOUR_GITHUB_USERNAME with your Github username. Add a Git remote for the original repository (upstream).
git clone https://github.com/YOUR_GITHUB_USERNAME/pythonclub.git
cd pythonclub
git remote add upstream https://github.com/pucdata/pythonclub.git
git fetch --all
git remote -v
Let’s say you want to create a tutorial about astropy. The best way is to create a branch from master and develop the new code on that branch. Let’s call the branch astropy.
git checkout -b astropy
Now you are in the astropy branch and you can add any content you want. Even you can modify files that were already in the repository.
For tracking the new files you need to use git add
For commiting the changes you need to use git commit
Replace TYPE_A_LOG_MESSAGE by a short message describing the changes
git add -A
git commit -m "TYPE_A_LOG_MESSAGE"
Push the changes to your forked copy of the repository (it's called origin). Since you are pushing content for the first time, you need to specify where are you pushing. In this case, we are pushing to the astropy branch hosted in the remote origin.
git push --set-upstream origin astropy
The next time you push content to the repository you just need to execute git push
git push
The previous instructions were for forking the pythonclub reposotiory and pushing new content to the forked repository (YOUR_GITHUB_USERNAME). Now you will open a pull-request to push the content to the original repository (pucdata)
A new window will be opened and you should type a title and comment for the pull-request. This information will be read by the manager of pucdata, so try to be concise and clear. Once you are done, click the green button Create pull request.
The most important branch in your repository is called master. You should reserve this branch to have an identical copy of the master branch in the original repository (https://github.com/pucdata/pythonclub). For adding new content or modifying code, you should always create a new branch, let's say astropy.
To keep synced the master branch in your forked repository with the original repository, execute the following commands
git checkout master
git fetch upstream
git rebase upstream/master
git push
In [ ]: